// 封装自己的工具
/**
 * 获取cookie的工具
 * @param {*要获取的cookie的name名} key 
 */
function getCookie (key) {
  var cookie = document.cookie;
  var cookiearr = cookie.split("; ");//["password=123456","age=88","sex=男"]
  for (var i = 0; i < cookiearr.length; i++) {
    var newarr = cookiearr[i].split("=")
    if (key == newarr[0]) {
      return newarr[1]
    }
  }
}
/**
 * 设置cookie的方法
 * @param {*要设置的cookie的name名} name 
 * @param {*要设置的cookie的value名} value 
 * @param {*要设置的cookie的过期时间，为分钟} exMin 
 */
function setCookie (name, value, exMin) {
  var cookieStr = name + "=" + value
  document.cookie = cookieStr;
  if (exMin) {
    var date = new Date(); //系统时间
    var mydate = new Date(date.getTime() + exMin * 60000)//
    cookieStr += "; expires=" + mydate;
    document.cookie = cookieStr;
  }
}
/**
 * 删除cookie的方法
 * @param {*要删除的cookie的name名} key
 */
function delCookie (key) {
  var date = new Date();
  date.setDate(-1) //设置过期时间为以前的时间 完成删除cookie 
  document.cookie = key + "='';expires=" + date.toUTCString();
}
/**
 * 获取地址栏参数
 * @param {*要的地址栏参数的name名} key
 */
function getParams (key) { //id   888   age  28  name  zhang
  var searchStr = location.search.substr(1);//id=888&age=28&name=zhang
  var arr = searchStr.split("&");//["id=888","age=28","name=zhang"]
  for (var i = 0; i < arr.length; i++) {
    var parr = arr[i].split("="); //["id",888]   ["age",28]  ["name","zhang"]
    if (key == parr[0]) {
      return parr[1]
    }
  }
}